package com.jackaltsc.mydemodatastorage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.jackaltsc.mydemodatastorage.externalstorage.ExternalActivity;
import com.jackaltsc.mydemodatastorage.internalstorage.InternalActivity;
import com.jackaltsc.mydemodatastorage.sharedpreferences.SharedPreActivity;
import com.jackaltsc.mydemodatastorage.sqlite.SQLiteActivity;
import com.jackaltsc.mydemodatastorage.contentprovider.ContentProvicerActivity;

/**
 * 主Activity 首界面
 */
public class MainActivity extends Activity implements OnClickListener {

    private Button btnExternal, btnInternal, btnSp, btnSqlite, btnSqliteCV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_main);

        initView();

    }

    private void initView() {

        btnExternal = (Button) findViewById(R.id.btn_external);
        btnInternal = (Button) findViewById(R.id.btn_internal);
        btnSp = (Button) findViewById(R.id.btn_preferences);
        btnSqlite = (Button) findViewById(R.id.btn_sqlite);
        btnSqliteCV = (Button) findViewById(R.id.btn_sqlitecv);

        initEvent();
    }

    private void initEvent() {

        btnExternal.setOnClickListener(this);
        btnInternal.setOnClickListener(this);
        btnSp.setOnClickListener(this);
        btnSqlite.setOnClickListener(this);
        btnSqliteCV.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.btn_external:
                startActivity(new Intent(MainActivity.this, ExternalActivity.class));
                break;

            case R.id.btn_internal:
                startActivity(new Intent(MainActivity.this, InternalActivity.class));
                break;

            case R.id.btn_preferences:
                startActivity(new Intent(MainActivity.this, SharedPreActivity.class));
                break;

            case R.id.btn_sqlite:
                startActivity(new Intent(MainActivity.this, SQLiteActivity.class));
                break;

            case R.id.btn_sqlitecv:
                startActivity(new Intent(MainActivity.this, ContentProvicerActivity.class));
                break;

        }

    }

}
